package com.cby.jetpack.sample.binding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.cby.jetpack.sample.R
import com.cby.jetpack.sample.binding.data.Image2
import com.cby.jetpack.sample.binding.data.ImageInfo
import com.cby.jetpack.sample.binding.listener.MyOnClickListener
import com.cby.jetpack.sample.databinding.ActivityDataBindConverterBinding
import com.cby.jetpack.sample.ext.dataBinding

/**
 * @description: Test
 *
 * @author ChenBaoyang
 * @date 8/10/21 15:49
 */
class TestDataBindingConverterActivity : AppCompatActivity(), MyOnClickListener{

    private val url = "https://ae01.alicdn.com/kf/U76a18e0d315e407a8daf3d91de033e31i.jpg"

    private val image = Image2("美女图片", url)

    private val binding: ActivityDataBindConverterBinding by dataBinding(R.layout.activity_data_bind_converter)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.listener = this
        binding.image = image
    }

    override fun onClick() {
        val oldValue = image.show.get()
        image.show.set(!oldValue)
        if(image.isShowTitle.get() == 1) {
            image.isShowTitle.set(0)
        }else{
            image.isShowTitle.set(1)
        }
    }
}